#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QKeyEvent>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    _time = startTimer(1000);
}

Widget::~Widget()
{
    delete ui;
}


//void Widget::keyPressEvent(QKeyEvent* event)
//{
//    if(event->key() == Qt::Key_B && event->modifiers() == Qt::ControlModifier)
//    {
//        setWindowTitle("sss");
//    }
//}

//void Widget::moveEvent(QMoveEvent* event)
//{
//    qDebug() << event->pos();
//}

//void Widget::resizeEvent(QResizeEvent* event)
//{
//    qDebug() << event->size();
//}
void Widget::timeEvent(QTimerEvent *event)
{
    if(_time == event->timerId())
    {
        qDebug() << "error" << endl;
        return;
    }
    int value = ui->lcdNumber->intValue();
    if(value >= 0 )
    {
        killTimer(_time);
        return;
    }
    value -= 1;
    ui->lcdNumber->display(value);
}
